package exception;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import javax.smartcardio.CardChannel;
import java.sql.SQLOutput;

//程序异常
public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("开始了");
        try {
            String name = " ";

        /*
         当jvm执行程序遇到一个异常时就会实例化该异常并将其抛出
         */
            System.out.println(name.length());
            System.out.println(name.charAt(1));
            System.out.println(Integer.parseInt(name));
            //try语句块中报错语句下面的内容都不会被执行
            System.out.println("!!!!!!!!!!!!!");
       /* } catch (NullPointerException e) {
            System.out.println("解决空指针异常");
        } catch (StringIndexOutOfBoundsException e) {
            System.out.println("下标越界异常");
        }*/
        }catch (NullPointerException | StringIndexOutOfBoundsException e){
            System.out.println("出现空指针或下标越界的统一解决方法");
        }catch (Exception e){
            System.out.println("不知道 反正就是出了个错误 能运行就行");
        }
        System.out.println("结束了");
    }

}
